//
//  NavigationCommanView.swift
//  GreenDeal
//
//  Created by Moennig Q on 21/12/2022.
//

import UIKit
import SnapKit
class PanleInverterListBaseView: GreenNaviBarView {
    let contentBackView = View(hexStr: "#FFFFFFFF")
    let scanBtn = LayoutButton(.top,at: 10)
    let addManuallyBtn = LayoutButton(.top,at: 10)
    let bottomView = View(hexStr: "#FFFFFFFF")
    
    override func setUpView() {
        //********bottom view
        self.addSubview(bottomView)
        bottomView.snp.makeConstraints { make in
            make.bottom.equalToSuperview()
            make.left.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
        }
        let horizionalLineView = View(hexStr: Constant.SeparatorColorHexStr)
        bottomView.addSubview(horizionalLineView)
        horizionalLineView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.right.equalToSuperview()
            make.height.equalTo(1)
        }
        let vertialLineView = View(hexStr: Constant.SeparatorColorHexStr)
        bottomView.addSubview(vertialLineView)
        vertialLineView.snp.makeConstraints { make in
            make.top.equalTo(horizionalLineView)
            make.centerX.equalToSuperview()
            make.width.equalTo(1)
            make.height.equalTo(90)
            make.bottom.equalTo(self.safeAreaLayoutGuide.snp.bottom)
        }
        scanBtn.setBtnInfo(R.string.localizable.scanBarcode(),hexStr: "#292D32",textFont: R.font.interMedium(size: 15),imageName: "installation_detail_panelnumber_scanbarcode")
        bottomView.addSubview(scanBtn)
        scanBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.height.width.greaterThanOrEqualTo(0)
            make.centerX.equalToSuperview().multipliedBy(1.5)
        }
        //
        addManuallyBtn.setBtnInfo(R.string.localizable.addManually(),hexStr: "#292D32",textFont: R.font.interMedium(size: 15),imageName: "installation_detail_panelnumber_addmanully")
        bottomView.addSubview(addManuallyBtn)
        addManuallyBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.height.width.greaterThanOrEqualTo(0)
            make.centerX.equalToSuperview().multipliedBy(0.5)
        }
        //contentBackView
        contentBackView.drawCorner(byRoundingCorners: [.topLeft,.topRight],radii: 16)
        contentBackView.backgroundColor = .white
        self.addSubview(contentBackView)
        contentBackView.snp.makeConstraints { make in
            make.top.equalTo(topBackView.snp.bottom).offset(-20)
            make.left.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
            make.bottom.equalTo(bottomView.snp.top)
        }
        
    }
    func hideBottomBtns(_ hideFlag: Bool){
        if hideFlag {//隐藏
            bottomView.snp.remakeConstraints { make in
                make.bottom.equalToSuperview()
                make.left.right.equalToSuperview()
                make.height.equalTo(0)
            }
        }else{//显示
            bottomView.snp.remakeConstraints { make in
                make.bottom.equalTo(self.safeAreaLayoutGuide.snp.bottom)
                make.left.right.equalToSuperview()
                make.height.equalTo(90)
            }
        }
    }
}

